package com.zhuiYun.project.api.dynamicstate.service.Impl;

import com.zhuiYun.project.api.dynamicstate.entity.DynamicStateEntity;
import com.zhuiYun.project.api.dynamicstate.mapper.DynamicStateMapper;
import com.zhuiYun.project.api.dynamicstate.service.DynamicStateService;
import com.zhuiYun.project.common.errorCode.CommonException;
import com.zhuiYun.project.common.errorCode.EmErrorCode;
import com.zhuiYun.project.common.response.CommonResult;
import com.zhuiYun.project.util.ObjectUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassName:DynamicStateServiceImpl
 * @descriptions: 主题ServiceImpl
 * @Author: zq
 * @Date 2023/4/18 16:09
 */
@Service
public class DynamicStateServiceImpl implements DynamicStateService {
    @Resource
    DynamicStateMapper dynamicStateMapper;

    /**
     * @description: 主题管理查询方法
     * @author: zq
     * @date: 2023/4/18 16:22
     * @param: []
     * @return: com.zhuiYun.project.common.response.CommonResult
     **/
    @Override
    public CommonResult dynamicStateByState() throws CommonException {
        DynamicStateEntity dynamicStateEntity = dynamicStateMapper.dynamicStateByState();
        if (ObjectUtils.isNotEmpty(dynamicStateEntity)) {
            return CommonResult.ok(dynamicStateEntity);
        } else {
            return CommonResult.error(EmErrorCode.ID_NOT_OBJECT);
        }
    }

    /**
     * @param id
     * @Author kdj
     * @Description 获取商家信息
     * @Date 2023/5/16 10:04
     * @Return com.zhuiYun.project.common.response.CommonResult
     */
    @Override
    public CommonResult getMerchantInfo(int id) {
        DynamicStateEntity dynamicStateEntity = dynamicStateMapper.getMerchantInfo(id);
        if (ObjectUtils.isNotEmpty(dynamicStateEntity)) {
            return CommonResult.ok(dynamicStateEntity);
        } else {
            return CommonResult.error(EmErrorCode.ID_NOT_OBJECT);
        }
    }
}
